<template>
  <van-grid direction="vertical" :column-num="5">
    <van-grid-item
      v-for="item in category"
      :key="item.categoryId"
      :icon="item.imgUrl"
      :text="item.name"
      to="/product-list"
    />
  </van-grid>
</template>

<script>
import { getCategory } from "../../api/api";
export default {
  data() {
    return {
      category: [],
    };
  },
  created() {
    getCategory((res) => {
      // console.log(res.data);
      let Category = res.data;
      let count = res.data[0].categoryId
      Category.forEach((item) => {
        count++;
        item.categoryId = count
      });
      this.category = res.data;
    });
  },
};
</script>

<style lang="scss" scoped>
.category-list {
  width: 100%;
  flex-wrap: wrap;

  div {
    display: flex;
    flex-direction: column;
    width: 20%;
    text-align: center;
  }
}
</style>

<style>
.van-icon__image {
  width: 57px;
  height: 57px;
}
</style>